package com.hly.musicbackground.result;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.Date;

@Data
@ApiModel("响应数据")
public class Result<T> {
    @ApiModelProperty(value = "响应数据")
    private T data;//响应数据
    @ApiModelProperty(value = "响应码",required = true)
    private Integer code;//响应码
    @ApiModelProperty(value = "响应消息",required = true)
    private String msg;//响应消息
    @ApiModelProperty(value = "请求时间",required = true)
    private Date time = new Date();//请求时间

    public Result() {
    }

    public Result(Integer code, T data) {
        this.data = data;
        this.code = code;
    }

    public Result(Integer code, T data, String msg) {
        this.data = data;
        this.code = code;
        this.msg = msg;
    }

    public static Result ok(){
        return Result.ok(null);
    }

    public static Result ok(Object t){
        return new Result(Code.OK, t,  "成功");
    }
}
